package com.huangliusong.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("weixin")
public class WeixinController {
	@GetMapping("/auth")
	public void getCode(@RequestParam("code") String code) {
		System.err.println("code=" + code);

		String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx1c60da6d68546e03&secret=048ca43bddd99130095792f92d9c4079&code="
				+ code + "&grant_type=authorization_code";
		RestTemplate restTemplate = new RestTemplate();
		String response = restTemplate.getForObject(url, String.class);
		System.err.println(response);

	}
}
